using System;
using UnityEngine;
using UnityEngine.UI;

namespace RedNoteModule.Test
{
    public class RedNoteTester : MonoBehaviour
    {
        [SerializeField] private InputField m_redNoteNameField;
        [SerializeField] private Button m_enableBtn;
        [SerializeField] private Button m_disableBtn;

        private void Awake()
        {
            m_enableBtn.onClick.AddListener(OnEnableBtnClick);
            m_disableBtn.onClick.AddListener(OnDisableBtnClick);
        }

        private void OnEnableBtnClick()
        {
            if (!string.IsNullOrEmpty(m_redNoteNameField.text))
            {
                ChangeRedNoteState(m_redNoteNameField.text, true);
            }
        }

        private void OnDisableBtnClick()
        {
            if (!string.IsNullOrEmpty(m_redNoteNameField.text))
            {
                ChangeRedNoteState(m_redNoteNameField.text, false);
            }
        }

        private void ChangeRedNoteState(string key, bool state)
        {
            RedNoteMgr.Instance.SetRedNoteValue(key, state);
        }
    }
}


